# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer:
pkgname=ocaml-re
_pkgname=re
pkgver=1.10.4
pkgrel=1
pkgdesc="Pure OCaml regular expressions, with support for Perl and POSIX-style strings"
url="https://github.com/ocaml/ocaml-re"
arch="all !riscv64"  # limited by ocaml aport
license="LGPL-2.1-or-later"
depends="ocaml-runtime ocaml-seq"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-seq-dev"
makedepends="$depends_dev dune ocaml"
checkdepends="ocaml-ounit-dev"
options="!check"
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.bz2::https://github.com/ocaml/ocaml-re/releases/download/$pkgver/re-$pkgver.tbz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; for path in $(find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.cmx' -o \
			-name '*.cmxa' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\))
	do
		amove "$path"
	done
}

sha512sums="
92b05cf92c389fa8c753f2acca837b15dd05a4a2e8e2bec7a269d2e14c35b1a786d394258376648f80b4b99250ba1900cfe68230b8385aeac153149d9ce56099  ocaml-re-1.10.4.tar.bz2
"
